package cn.keyvalue.ccf.common.object;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

/**
 * 超链接对象
 * 
 * @author wangxinning
 * 
 *         eg:<a target="_blank" title="服装楼层" href=
 *         "http://c.fa.360buy.com/adclick?sid=2&cid=232&aid=3100&bid=0&unit=32968&advid=39307&guv=&url=http://sale.360buy.com/act/dAwkt5NeFYUxKTQM.html"
 *         >
 */
public class Hyperlink implements Serializable {

	// 访问地址
	private String url;
	// title属性
	private String title;
	// 链接名称
	private String name;

	public Hyperlink() {

	}

	public Hyperlink(String name, String url, String title) {
		this.url = url;
		this.title = title;
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}

	public String toHtml() {

		if (StringUtils.isBlank(url)) {
			return name;
		} else {
			return "<a href='" + url + "' title='" + title + "'>" + name
					+ "</a>";
		}
	}
	
	public String toBlankHtml() {

		if (StringUtils.isBlank(url)) {
			return name;
		} else {
			return "<a href='" + url + "' title='" + title + "' target='_blank' >" + name
					+ "</a>";
		}
	}

	private static final long serialVersionUID = -9155170178695926838L;

}
